package com.groupbuying.cheetah.service.impl;

import com.groupbuying.cheetah.dao.TmpOrderFlowDao;
import com.groupbuying.cheetah.service.TmpOrderFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 拆分CheetahTmpOrderFlow大sql
 * @Author yangmeng
 * @Date 2019/10/31 17:20
 */
@Service
public class TmpOrderFlowServiceImpl implements TmpOrderFlowService {

    @Autowired
    private TmpOrderFlowDao tmpOrderFlowDao;

    /**
     * 收款台管理通过uuId查询
     */
    @Override
    public Map<String, Object> getStoreCheckoutCounterList(String[] uuId) {
        List<Map> mapList = tmpOrderFlowDao.getStoreCheckoutCounterList(uuId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String uuIds = (String) map.get("uuid");
            maps.put(uuIds, map);
        }
        return maps;
    }

    /**
     * 商户主信息通过uuId查询
     */
    @Override
    public Map<String, Object> getStoreMainInfoList(String[] uuId) {
        List<Map> mapList = tmpOrderFlowDao.getStoreMainInfoList(uuId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String uuIds = (String) map.get("uuid");
            maps.put(uuIds, map);
        }
        return maps;
    }

    /**
     * 订单和支付单关联关系通过orderId查询
     */
    @Override
    public Map<String, Object> getPayOrderRelList(String[] orderId) {
        List<Map> mapList = tmpOrderFlowDao.getPayOrderRelList(orderId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String orderIds = (String) map.get("order_id");
            maps.put(orderIds, map);
        }
        return maps;
    }

    /**
     * 订单支付主记录通过id查询
     */
    @Override
    public Map<String, Object> getPayInfoList(String[] id) {
        List<Map> mapList = tmpOrderFlowDao.getPayInfoList(id);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String ids = (String) map.get("id");
            maps.put(ids, map);
        }
        return maps;
    }

    /**
     * 结算中心分账主信息表通过orderId查询
     */
    @Override
    public Map<String, Object> getSettleUshopSplitMaininfoList(String[] orderId) {
        List<Map> mapList = tmpOrderFlowDao.getSettleUshopSplitMaininfoList(orderId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String orderIds = (String) map.get("order_id");
            maps.put(orderIds, map);
        }
        return maps;
    }

    /**
     * 优店商户资金流水表通过externalId查询
     */
    @Override
    public Map<String, Object> getSettleUshopFlowStoreList(String[] externalId) {
        List<Map> mapList = tmpOrderFlowDao.getSettleUshopFlowStoreList(externalId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String externalIds = (String) map.get("external_id");
            maps.put(externalIds, map);
        }
        return maps;
    }

    /**
     * 服务商账号表通过providerId查询
     */
    @Override
    public Map<String, Object> getStoreAccountList(String[] providerId) {
        List<Map> mapList = tmpOrderFlowDao.getStoreAccountList(providerId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String providerIds = (String) map.get("provider_id");
            maps.put(providerIds, map);
        }
        return maps;
    }

    /**
     * 代理商信息表通过id查询
     */
    @Override
    public Map<String, Object> getSysAgentInfoList(String[] id) {
        List<Map> mapList = tmpOrderFlowDao.getSysAgentInfoList(id);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String ids = (String) map.get("id");
            maps.put(ids, map);
        }
        return maps;
    }

    /**
     * 微信登录信息关联表通过customerId查询
     */
    @Override
    public Map<String, Object> getCustomerWxinfoRelList(String[] customerId) {
        List<Map> mapList = tmpOrderFlowDao.getCustomerWxinfoRelList(customerId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String customerIds = (String) map.get("customer_id");
            maps.put(customerIds, map);
        }
        return maps;
    }

    /**
     * 够样优店用户表通过customerId查询
     */
    @Override
    public Map<String, Object> getCustomerUshopList(String[] customerId) {
        List<Map> mapList = tmpOrderFlowDao.getCustomerUshopList(customerId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String customerIds = (String) map.get("customer_id");
            maps.put(customerIds, map);
        }
        return maps;
    }

    /**
     * 支付宝登录信息关联表通过customerId查询
     */
    @Override
    public Map<String, Object> getCustomerAliinfoRelList(String[] customerId) {
        List<Map> mapList = tmpOrderFlowDao.getCustomerAliinfoRelList(customerId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String customerIds = (String) map.get("customer_id");
            maps.put(customerIds, map);
        }
        return maps;
    }

    /**
     * 分账关联子表平台通过settleId查询
     */
    @Override
    public Map<String, Object> getSettleUshopSplitPlantformList(String[] settleId) {
        List<Map> mapList = tmpOrderFlowDao.getSettleUshopSplitPlantformList(settleId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String settleIds = (String) map.get("settle_id");
            maps.put(settleIds, map);
        }
        return maps;
    }

    /**
     * 优店分账关联子表商户表通过settleId查询
     */
    @Override
    public Map<String, Object> geSettleUshopSplitStoreList(String[] settleId) {
        List<Map> mapList = tmpOrderFlowDao.geSettleUshopSplitStoreList(settleId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String settleIds = (String) map.get("settle_id");
            maps.put(settleIds, map);
        }
        return maps;
    }

    /**
     * 分账关联子表通道费表通过settleId查询
     */
    @Override
    public Map<String, Object> getSettleUshopSplitChannleList(String[] settleId) {
        List<Map> mapList = tmpOrderFlowDao.getSettleUshopSplitChannleList(settleId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String settleIds = (String) map.get("settle_id");
            maps.put(settleIds, map);
        }
        return maps;
    }

    /**
     * 积分日志表通过payId查询
     */
    @Override
    public Map<String, Object> getCurrencyCustomerLogList(String[] payId) {
        List<Map> mapList = tmpOrderFlowDao.getCurrencyCustomerLogList(payId);
        Map<String, Object> maps = new HashMap<>();
        for (Map<String, Object> map : mapList ) {
            String payIds = (String) map.get("pay_id");
            maps.put(payIds, map);
        }
        return maps;
    }
}
